package com.steven.concurrent.join;

public class Joiner extends Thread {
	private Sleeper sleeper;
	public Joiner(String name, Sleeper sleeper) {
		super(name);
		this.sleeper = sleeper;
		start();
	}
	@Override
	public void run() {
		try {
			sleeper.join();  // 等待Sleeper醒来，才继续往下执行。  如果Sleeper被中断或者正常结束, Joiner将和Sleeper一同结束
		} catch (InterruptedException e) {
			System.out.println("Interrupted");
		}
		System.out.println(getName() + " join completed. ");
	}
}
